﻿Class MainWindow
    Protected m_Level As Long
    Protected m_SubWindow ' 当前显示子窗口
    Public Sub Initialize(ByVal Level As Long)
        m_Level = Level
        Dim bSystem As Boolean = True
        Dim bClerk As Boolean = True
        Dim bServe As Boolean = True
        Dim bBook As Boolean = True
        Dim bTakeout As Boolean = True
        Select Case m_Level
            Case 0 ' 经理(所有权限)
            Case 1 ' 后台服务员(前台营业模块和餐桌预订服务模块)
                bSystem = False
                bClerk = False
                bTakeout = False
            Case 2 ' 外卖送货员(外卖服务模块)
                bSystem = False
                bClerk = False
                bServe = False
                bBook = False
        End Select
        GroupSystem.IsEnabled = bSystem
        If bSystem Then
            GroupSystem.Visibility = Visibility.Visible
        Else
            GroupSystem.Visibility = Visibility.Collapsed
        End If
        GroupClerk.IsEnabled = bClerk
        If bClerk Then
            GroupClerk.Visibility = Visibility.Visible
        Else
            GroupClerk.Visibility = Visibility.Collapsed
        End If
        GroupServe.IsEnabled = bServe
        If bServe Then
            GroupServe.Visibility = Visibility.Visible
        Else
            GroupServe.Visibility = Visibility.Collapsed
        End If
        GroupBook.IsEnabled = bBook
        If bBook Then
            GroupBook.Visibility = Visibility.Visible
        Else
            GroupBook.Visibility = Visibility.Collapsed
        End If
        GroupTakeout.IsEnabled = bTakeout
        If bTakeout Then
            GroupTakeout.Visibility = Visibility.Visible
        Else
            GroupTakeout.Visibility = Visibility.Collapsed
        End If
    End Sub
    Sub New()
        ' 此调用是设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。
        TakeTable_Page1.Initialize()
        ChangePassWord_Page1.SetWindow(Me)
    End Sub

    Private Sub MenuItemExit_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItemExit.Click
        End
    End Sub

    Private Sub MenuItemLogOut_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles MenuItemLogOut.Click
        Dim Login_Form As New Login
        Login_Form.Show()
        Hide()
    End Sub

    Protected Sub HideSubWindow()
        If Not (m_SubWindow Is Nothing) Then
            If m_SubWindow.Visibility = Visibility.Visible Then
                m_SubWindow.Visibility = Visibility.Collapsed
                m_SubWindow.Initialize()
            End If
        End If
    End Sub

    Private Sub ButtonChangePassword_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonChangePassword.Click
        Title = "修改密码"
        HideSubWindow()
        m_SubWindow = ChangePassWord_Page1
        ChangePassWord_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonAddRemoveUser_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonAddRemoveUser.Click
        Title = "添加/删除用户"
        HideSubWindow()
        m_SubWindow = AddRemoveUser_Page1
        AddRemoveUser_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonAddRemoveMenu_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonAddRemoveMenu.Click
        Title = "添加/删除菜单"
        HideSubWindow()
        m_SubWindow = AddRemoveMenu_Page1
        AddRemoveMenu_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonAddRemoveTable_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonAddRemoveTable.Click
        Title = "添加/删除座位"
        HideSubWindow()
        m_SubWindow = AddRemoveTable_Page1
        AddRemoveTable_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonClerkManage_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonClerkManage.Click
        Title = "员工管理"
        HideSubWindow()
        m_SubWindow = ClerkManage_Page1
        ClerkManage_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonTakeTable_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonTakeTable.Click
        Title = "安排座位"
        HideSubWindow()
        m_SubWindow = TakeTable_Page1
        TakeTable_Page1.Initialize()
        TakeTable_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonTakeFood_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonTakeFood.Click
        Title = "点餐"
        HideSubWindow()
        m_SubWindow = TakeFood_Page1
        TakeFood_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonSee_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonSee.Click
        Title = "查看"
        HideSubWindow()
        m_SubWindow = See_Page1
        See_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonServe_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonServe.Click
        Title = "上菜"
        HideSubWindow()
        m_SubWindow = Serve_Page1
        Serve_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonBill_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonBill.Click
        Title = "结账"
        HideSubWindow()
        m_SubWindow = Bill_Page1
        Bill_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonTableBook_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonTableBook.Click
        Title = "餐桌预订"
        HideSubWindow()
        m_SubWindow = TableBook_Page1
        TableBook_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonTakeoutOrder_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonTakeoutOrder.Click
        Title = "点餐"
        HideSubWindow()
        m_SubWindow = TakeoutOrder_Page1
        TakeoutOrder_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub ButtonTakeoutDeliver_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles ButtonTakeoutDeliver.Click
        Title = "送货"
        HideSubWindow()
        m_SubWindow = TakeoutDeliver_Page1
        TakeoutDeliver_Page1.Visibility = Visibility.Visible
    End Sub

    Private Sub MainWindow_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles Me.Closing
        End
    End Sub
End Class
